<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $this->systemName;?></title>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/css/main.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/jquery.js"></script>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/js/formValidator.jquery/style.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/formValidator.jquery/cn.js"></script>

<!--时间选择器-->
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/date/calendar.js"></script>
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/date/lang/cn_utf8.js"></script>
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/date/calendar-setup.js"></script>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/js/date/calendar-blue.css" />
</head>

<body>
	<div id="main">
		<div id="navigation">当前位置：<a href="<?php echo $this->projectUrl(array('action'=>'index'));?>">主协议列表</a> &gt; <span id="focus">添加主协议</span></div>
		<div id="body">
			<div id="edit">
				<form id="editForm" name="editForm" method="post" action="">
					<table class="table">
						<tr>
							<td colspan="2">*为必填项</td>
						</tr>
						<tr>
							<td width="20%">复制来源主协议版本号：</td>
							<td>
								<select name="copyMainVersion" id="copyMainVersion">
								<?php foreach($this->mainRows as $row) {?>
									<option value="<?php echo $row['mainVersion'];?>"><?php echo $row['mainVersion'];?></option>
									<?php }?>
								</select>
							</td>
						</tr>
						<tr>
							<td width="20%">主协议版本号：</td>
							<td>
								<input name="mainVersion" type="text" class="validate[callback[checkPactVersion,1]] input" id="mainVersion" value="" size="30" style="width:300px;" />
								* 
								<br/>格式例如：v3.0,不允许修改。
							</td>
						</tr>
						<tr>
							<td width="20%">协议当前状态：</td>
							<td>	
								<input name="pactStatus" type="radio" class="type" value="1" checked="checked" /> 上线
								<input name="pactStatus" type="radio" class="type" value="2" /> 开发
								<input name="pactStatus" type="radio" class="type" value="0" /> 过期	
							</td>
						</tr>
						<tr>
							<td width="20%">保留事件ID定义区间：</td>
							<td><input name="keepStartEventId" type="text" class="input" id="keepStartEventId" value="" size="10" style="width:50px;" /> - <input name="keepEndEventId" type="text" class="input" id="keepEndEventId" value="" size="10" style="width:50px;" /> </td>
						</tr>
						<tr>
							<td width="20%">自定义事件ID定义区间：</td>
							<td><input name="userDefineStartEventId" type="text" class="input" id="userDefineStartEventId" value="" size="10" style="width:50px;" /> - <input name="userDefineEndEventId" type="text" class="input" id="userDefineEndEventId" value="" size="10" style="width:50px;" /> </td>
						</tr>
						<tr>
							<td width="20%">协议上线日期：</td>
							<td><input name="pactOnlineDate" type="text" class="input" id="pactOnlineDate" value="" size="18" style="width:120cpx;" />
							<script type="text/javascript">Calendar.setup({"ifFormat":"%Y-%m-%d","firstDay":0,"showsTime":true,"showOthers":false,"timeFormat":24,"inputField":"pactOnlineDate","button":"pactOnlineDate"});</script>
							</td>
						</tr>
						<tr>
							<td width="20%">协议编写人：</td>
							<td><?php echo $this->pactAuthor;?><input name="pactAuthor" type="hidden" id="pactAuthor" value="<?php echo $this->pactAuthor;?>"/></td>
						</tr>
						<tr>
							<td width="20%">备注：</td>
							<td><textarea name="pactNote" cols="30" rows="5" class="input" id="pactNote" style="width:300px;"></textarea></td>
						</tr>
						<tr>
							<td width="20%">&nbsp;</td>
							<td><input type="submit" name="button" id="button" value="提交" class="button"/></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</div>

<script language="javascript">
function checkPactVersion(account)
{
    var url = '<?php echo $this->projectUrl(array('action'=>'get-main-pact-version-is-exists-by-json', 'account'=>'{account}'), NULL, false);?>'+'?rand/' + Math.random();
	url = url.replace('{account}', account);
	checkResult = {'isRight':true, 'message':''};
	
	if ($.trim($("#mainVersion").val()) == '') {
		return checkResult = {'isRight':false, 'message':'主协议版本号。'};
	}
	if (account != '') {
		$.ajax({
			type: "GET",
			url: url,
			dataType: "json",
			async: false,
			success: function(data){
				if (data == 1) {
					checkResult = {'isRight':false, 'message':'* 此协议版本号已存在，请换一个。'};
				}
			} 
		}); 
	}
	return checkResult;
}

$("#editForm").submit(function(){
	return true;
});
</script>
</body>
</html>